#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
bool isPowerOfThree(int n) {
    if (n <= 0)
        return false;
    int tmp = n;
    while (tmp % 3 == 0)
    {
        tmp /= 3;
    }
    if (tmp == 1)
        return true;
    else
        return false;
}
int main()
{
    printf("%d",isPowerOfThree(9));
    return 0;
}